import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { VarletImportResolver } from '@varlet/import-resolver'

export default defineConfig({
  server: {
    port: 3002,

    // 代理
    proxy: {
      '/chat': {
        target: 'http://api.qingyunke.com/api.php',
        // target: 'http://api.ooyyh.top',
        changeOrigin: true,

        rewrite: path => path.replace(/^\/chat/, '')
      }
    }
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [VarletImportResolver({ autoImport: true })],
      imports: ['vue', 'vue-router', 'pinia'],
      dts: './auto-import.d.ts'
    }),
    Components({
      resolvers: [VarletImportResolver()]
    })
  ],
  resolve: {
    alias: {
      '@': '/src'
    }
  }
})
